import '../../../../../../../utils/util.dart';

class Brn2RowDelegate implements BrnMultiDataPickerDelegate {
  int firstSelectedIndex = 0;
  int secondSelectedIndex = 0;
  List<Map<String, List>> list;
  int column = 2;
  Brn2RowDelegate({
    this.firstSelectedIndex = 0,
    this.secondSelectedIndex = 0,
    this.column = 2,
    required this.list,
  });

  @override
  int numberOfComponent() {
    return column;
  }

  @override
  int numberOfRowsInComponent(int component) {
    if (0 == component) {
      return list.length;
    } else {
      Map<String, List> secondMap = list[firstSelectedIndex];
      return secondMap.values.first.length;
    }
  }

  @override
  String titleForRowInComponent(int component, int index) {
    if (0 == component) {
      return list[index].keys.first;
    } else {
      Map<String, List> secondMap = list[firstSelectedIndex];

      return secondMap.values.first[index].first;
    }
  }

  @override
  double? rowHeightForComponent(int component) {
    return null;
  }

  @override
  selectRowInComponent(int component, int row) {
    if (0 == component) {
      firstSelectedIndex = row;
    } else {
      secondSelectedIndex = row;
      print('_thirdSelectedIndex  is selected to $secondSelectedIndex');
    }
  }

  @override
  int initSelectedRowForComponent(int component) {
    if (0 == component) {
      return firstSelectedIndex;
    } else {
      print('_thirdSelectedIndex  is selected to $secondSelectedIndex');
      return secondSelectedIndex;
    }
  }
}
